yazrkisvs3vvvsv33svrhetrjsvyvsvvyjsvsvs
tavsuysvssvvjvvyjyjkvsvqd
qfogsvvsvsegjdgdfgdskhgdksvqsvshdqsd
#1731161645
clear
#1731161646
ls
#1731161647
pwd
#1731161671
cd /home/dimark93
#1731161672
ls
#1731161701
cd public_html/
#1731161707
ls
#1731161937
tar -xvzf dimark93.tar.gz -C /home/dimark93/public_html/ /dimark93/homedir/public_html/
#1731162053
tar -xvzf dimark93.tar.gz -C /home/dimark93/public_html/ dimark93/homedir/public_html/
#1731162534
clear
#1731162796
tar -xvzf dimark93.tar.gz -C /home/dimark93/ dimark93/mysql
#1731162851
clear
#1731162860
cd ..
#1731162864
ls
#1731162879
pwd
#1731162890
cd dimark93/
#1731162891
ls
#1731162897
cd homedir
#1731162897
ls
#1731162910
cd ..
#1731162910
ls
#1731162912
cd mysql/
#1731162913
ls
#1731162933
mysql -u dimark93 -p
#1731163726
exit;
#1731163743
cd
#1731163744
ls
#1731163750
cd public_html/
#1731163751
ls
#1731163764
pwd
#1731163779
ls
#1731163781
cd dimark93
#1731163781
ls
#1731163789
cd homedir/
#1731163790
ls
#1731163792
cd public_html/h
#1731163794
cd public_html/
#1731163795
ls
#1731163802
pwd
#1731163868
mv * ../../../
#1731163870
ls
#1731163873
cd ..
#1731163881
ls
#1731163884
pwd
#1731163906
ls
#1731163922
mv dimark93.tar.gz ../
#1731163923
ks
#1731163924
ls
#1731163933
clear
#1731163934
ls
#1731163937
pwd
#1731163959
cd ..
#1731163960
l
#1731163962
ls
#1731163966
pwd
#1731163976
cd dimark93
#1731163977
ls
#1731163980
cd mysql/
#1731163982
ls
#1731163990
clear
#1731163990
ls
#1731163993
clear
#1731163994
pwd
#1731163996
cd ..
#1731164022
mv mysql/ ../
#1731164024
ls
#1731164028
cd homedir/
#1731164029
ls
#1731164032
cd mail/
#1731164033
ls
#1731164039
clear
#1731164039
ls
#1731164043
pwd
#1731164045
cd ..
#1731164046
ls
#1731164048
cd ..
#1731164049
ls
#1731164051
cd ..
#1731164052
ls
#1731164058
cd mysql/
#1731164059
ls
#1731164080
mkdir backup
#1731164083
clear
#1731164084
ls
#1731164097
rm -rf backup/
#1731164097
ls
#1731164099
cd ..
#1731164100
ls
#1731164101
clear
#1731164102
ls
#1731164105
mkdir backup
#1731164113
mv dimark93.tar.gz backup/
#1731164118
pwd
#1731164135
mv dimark93 backup/
#1731164136
ls
#1731164144
mv mysql/ backup/
#1731164146
ls
#1731164148
cd backup/
#1731164148
ls
#1731164160
clear
#1731164163
ls
#1731164232
celar
#1731164233
clear
#1731164234
ls
#1731164236
cd ..
#1731164237
ls
#1731164267
clear
#1731164269
ls
#1731164279
cd backup/
#1731164282
cd ..
#1731164283
ls
#1731164285
cd mail/
#1731164285
ls
#1731164290
cd ..
#1731164292
clear
#1731164294
ls
#1731164295
cd backup/
#1731164296
ls
#1731164304
cd dimark93
#1731164305
ls
#1731164310
clear
#1731164312
ls
#1731164313
cd ..
#1731164313
ls
#1731164448
tar -xvzf dimark93.tar.gz -C . dimark93/homedir/mail
#1731164518
clear
#1731164519
ls
#1731164533
cd ..
#1731164533
ls
#1731164536
cd ..
#1731164537
ls
#1731164555
cd backup
#1731164560
ls
#1731164563
cd ..
#1731164563
ls
#1731164571
pwd
#1731164581
cd var/
#1731164581
ls
#1731164587
ls -la
#1731164613
cd log/
#1731164615
ls
#1731164618
ls -la
#1731164639
nano lastlog 
#1731164660
cd /
#1731164661
ls
#1731164664
cd backup/
#1731164665
ls
#1731164676
celar
#1731164677
clear
#1731164677
ls
#1731164687
clear
#1731164688
ls
#1731164704
cd /home/dimark93
#1731164705
ls
#1731164709
cd backup/
#1731164715
l
#1731164716
ls
#1731164720
cd dimark93
#1731164720
ls
#1731164722
cd homedir/
#1731164723
ls
#1731164725
cd mail/
#1731164726
ls
#1731164739
clear
#1731164740
ls
#1731164753
ls -la
#1731164775
pqd
#1731164776
pwd
#1731164821
cp dimark.co/ ../../../../mail/
#1731164829
cp -r  dimark.co/ ../../../../mail/
#1731164836
cd 
#1731164837
ls
#1731164839
cd public_html/
#1731164842
cd ..
#1731164843
clear
#1731164845
pwd
#1731164847
ls
#1731164849
cd mail/
#1731164849
ls
#1731164851
cd dimark.co/
#1731164852
ls
#1766098547
node --v
#1766098551
node -v
#1776462470
which pandoc
#1776463234
php -r "echo extension_loaded('gd') ? 'GD OK' : 'NO GD'; echo extension_loaded('imagick') ? ' | Imagick OK' : ' | NO Imagick';"
#1776465675
tail -20 /var/log/apache2/error_log
#1776465712
cat /home/dimark93/public_html/supercerebro/.htaccess
#1776465723
cat /home/dimark93/public_html/supercerebro/api/.htaccess 2>/dev/null || echo "No existe"
#1776465753
php -l /home/dimark93/public_html/supercerebro/api/proposals.php
#1776465760
php -r "require '/home/dimark93/public_html/supercerebro/api/proposals.php';" 2>&1 | head -20
#1776465777
php -l /home/dimark93/public_html/supercerebro/api/proposals.php 2>&1
#1776466007
php -d display_errors=1 -d error_reporting=32767 /home/dimark93/public_html/supercerebro/api/proposals.php 2>&1 | head -5
#1776466088
php -l /home/dimark93/public_html/supercerebro/api/proposals.php 2>&1
#1776466811
php-1
#1776467319
php -l /home/dimark93/public_html/supercerebro/api/proposals.php 2>&1
#1776467656
php -r "
require '/home/dimark93/public_html/supercerebro/config.php';
\$params = ['access_key'=>SCREENSHOTONE_ACCESS,'url'=>'https://cliniodontos.com','viewport_width'=>'1280','viewport_height'=>'800','format'=>'jpg','image_quality'=>'75','full_page'=>'false','delay'=>'2','cache'=>'true','cache_ttl'=>'2592000','block_ads'=>'true','block_cookie_banners'=>'true'];
ksort(\$params);
\$query = http_build_query(\$params);
\$sig = hash_hmac('sha256', \$query, SCREENSHOTONE_SECRET);
\$url = 'https://api.screenshotone.com/take?' . \$query . '&signature=' . \$sig;
echo \$url . PHP_EOL;
"php -r "require '/home/dimark93/public_html/supercerebro/config.php'; \$params=['access_key'=>SCREENSHOTONE_ACCESS,'url'=>'https://cliniodontos.com','viewport_width'=>'1280','viewport_height'=>'800','format'=>'jpg','image_quality'=>'75','full_page'=>'false','delay'=>'2','cache'=>'true','cache_ttl'=>'2592000','block_ads'=>'true','block_cookie_banner
php -r "require '/home/dimark93/public_html/supercerebro/config.php'; \$params=['access_key'=>SCREENSHOTONE_ACCESS,'url'=>'https://cliniodontos.com','viewport_width'=>'1280','viewport_height'=>'800','format'=>'jpg','image_quality'=>'75','full_page'=>'false','delay'=>'2','cache'=>'true','cache_ttl'=>'2592000','block_ads'=>'true','block_cookie_banner
cat /home/dimark93/public_html/supercerebro/logs/proposal_error.log

cat /home/dimark93/public_html/supercerebro/logs/proposal_error.log




#1776467843
cat /home/dimark93/public_html/supercerebro/logs/proposal_error.log
#1776519551
php -l /home/dimark93/public_html/supercerebro/api/proposals.php 2>&1
#1776519566
php -d display_errors=1 -l /home/dimark93/public_html/supercerebro/api/proposals.php 2>&1
#1776529318
curl -s https://api.anthropic.com/v1/messages -H "x-api-key: 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" -H "anthropic-version: 2023-06-01" -H "content-type: application/json" -d '{"model":"claude-haiku-4-5-20251001","max_tokens":10,"messages":[{"role":"user","content":"hola"}]}'
#1776529340
curl -s https://api.anthropic.com
#1776529379
php -r "
\$ch = curl_init('https://api.anthropic.com/v1/messages');
curl_setopt(\$ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt(\$ch, CURLOPT_TIMEOUT, 10);
\$r = curl_exec(\$ch);
echo \$r ?: 'sin respuesta';
echo curl_error(\$ch);
curl_close(\$ch);
"php -r "\$ch=curl_init('https://api.anthropic.com/v1/messages');curl_setopt(\$ch,CURLOPT_RETURNTRANSFER,true);curl_setopt(\$ch,CURLOPT_TIMEOUT,10);\$r=curl_exec(\$ch);echo \$r?:'sin respuesta';echo curl_error(\$ch);curl_close(\$ch);"
#1776527767
cat /supercerebro/logs/proposal_error.log
#1776527815
cat /home/dimark93/public_html/supercerebro/logs/proposal_error.log
#1776527830
cat /home/dimark93/public_html/supercerebro/api/logs/proposal_error.log
#1776529134
tail -20 /home/dimark93/public_html/supercerebro/logs/proposal_error.log
#1776529197
grep -n "CREDIT_ERROR" /home/dimark93/public_html/supercerebro/api/competitive_analysis.php
#1776529216
grep "competitive\|comp" /home/dimark93/public_html/supercerebro/logs/proposal_error.log
#1776529224
grep "CLAUDE_API_KEY" /home/dimark93/public_html/supercerebro/config.php
#1776529248
curl https://api.anthropic.com/v1/messages   -H "x-api-key: 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"   -H "anthropic-version: 2023-06-01"   -H "content-type: application/json"   -d '{"model":"claude-haiku-4-5-20251001","max_tokens":10,"messages":[{"role":"user","content":"hola"}]}'
#1776529250
curl https://api.anthropic.com/v1/messages   -H "x-api-key: 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"   -H "anthropic-version: 2023-06-01"   -H "content-type: application/json"   -d '{"model":"claude-haiku-4-5-20251001","max_tokens":10,"messages":[{"role":"user","content":"hola"}]}'0DAA
#1776529277
>   -d '{"model":"claude-haiku-4-5-20251001","max_tokens":10,"messages":[{"role":"user","content":"hola"}]}'0DAA
#1776529293
El comando se pegó mal. Cópialo y pégalo así, todo en una sola línea:A
#1776529293
```bash
curl -s https://api.anthropic.com/v1/messages -H "x-api-key: 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" -H "anthropic-version: 2023-06-01" -H "content-type: application/json" -d '{"model":"claude-haiku-4-5-20251001","max_tokens":10,"messages":[{"role":"user","content":"hola"}]}'
```El comando se pegó mal. Cópialo y pégalo así, todo en una sola línea:
#1776529406
php -r "\$ch=curl_init('https://api.anthropic.com/v1/messages');curl_setopt(\$ch,CURLOPT_RETURNTRANSFER,true);curl_setopt(\$ch,CURLOPT_TIMEOUT,10);\$r=curl_exec(\$ch);echo \$r?:'sin respuesta';echo curl_error(\$ch);curl_close(\$ch);"
#1776529461
grep -n "CREDIT_ERROR\|SIN_CREDITOS" /home/dimark93/public_html/supercerebro/api/competitive_analysis.php
#1776529526
grep -n "showSinCreditosModal" /home/dimark93/public_html/supercerebro/index.php
#1776529563
A1920:function showSinCreditosModal() {A
#1776529563
2384:    if (data.error === 'SIN_CREDITOS') showSinCreditosModal();
#1776529563
2420:    if (data.error === 'SIN_CREDITOS') showSinCreditosModal();
#1776529565
2568:    if (data.error === 'SIN_CREDITOS') showSinCreditosModal();1920:function showSinCreditosModal() {
#1776529565
2384:    if (data.error === 'SIN_CREDITOS') showSinCreditosModal();
#1776529565
2420:    if (data.error === 'SIN_CREDITOS') showSinCreditosModal();
#1776529567
2568:    if (data.error === 'SIN_CREDITOS') showSinCreditosModal();1920:function showSinCreditosModal() {
#1776529567
2384:    if (data.error === 'SIN_CREDITOS') showSinCreditosModal();
#1776529567
2420:    if (data.error === 'SIN_CREDITOS') showSinCreditosModal();
#1776529728
2568:    if (data.error === 'SIN_CREDITOS') showSinCreditosModal();
#1776529729
php -r "
\$ch=curl_init('https://api.anthropic.com/v1/messages');
curl_setopt_array(\$ch,[CURLOPT_RETURNTRANSFER=>true,CURLOPT_POST=>true,CURLOPT_HTTPHEADER=>['Content-Type: application/json','x-api-key: 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','anthropic-version: 2023-06-01'],CURLOPT_POSTFIELDS=>json_encode(['model'=>'claude-sonnet-4-20250514','max_tokens'=>100,'messages'=>[['role'=>'user','content'=>'hola']]]),CURLOPT_TIMEOUT=>30,CURLOPT_SSL_VERIFYPEER=>false]);
echo curl_exec(\$ch);
curl_close(\$ch);
#1776529759
cat > /tmp/test_api.php << 'EOF'
<?php
$ch=curl_init('https://api.anthropic.com/v1/messages');
curl_setopt_array($ch,[CURLOPT_RETURNTRANSFER=>true,CURLOPT_POST=>true,CURLOPT_HTTPHEADER=>['Content-Type: application/json','x-api-key: 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','anthropic-version: 2023-06-01'],CURLOPT_POSTFIELDS=>json_encode(['model'=>'claude-sonnet-4-20250514','max_tokens'=>100,'messages'=>[['role'=>'user','content'=>'hola']]]),CURLOPT_TIMEOUT=>30,CURLOPT_SSL_VERIFYPEER=>false]);
echo curl_exec($ch);
curl_close($ch);
EOF

#1776529778
php /tmp/test_api.phpnano /tmp/test_api.php
#1776529780
nano /tmp/test_api.php
#1776529809
<?php
#1776529809
$ch=curl_init('https://api.anthropic.com/v1/messages');
#1776529809
curl_setopt_array($ch,[CURLOPT_RETURNTRANSFER=>true,CURLOPT_POST=>true,CURLOPT_HTTPHEADER=>['Content-Type: application/json','x-api-key: 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','anthropic-version: 2023-06-01'],CURLOPT_POSTFIELDS=>json_encode(['model'=>'claude-sonnet-4-20250514','max_tokens'=>100,'messages'=>[['role'=>'user','content'=>'hola']]]),CURLOPT_TIMEOUT=>30,CURLOPT_SSL_VERIFYPEER=>false]);
#1776529809
echo curl_exec($ch);
#1776529810
curl_close($ch);
#1776529853
php /tmp/test_api.php
#1776530215
grep -rn "Error HTTP 400\|Verifica tu API" /home/dimark93/public_html/supercerebro/
#1776530278
php /tmp/test_api.php
#1776531148
[dimark93@exclusive ~]$ php /tmp/test_api.php
#1776561116
/supercerebro/logs/proposal_error.log
#1776561138
Ejecuta este comando:
#1776561138
```bash
php -l /home/dimark93/public_html/supercerebro/api/proposals.php
```Ejecuta este comando:
#1776561211
php /home/dimark93/public_html/supercerebro/api/proposals.php 2>&1 | head -20
#1776561230
cat /home/dimark93/logs/dimark.co.error.log | tail -30
#1776561247
find /home/dimark93/logs -name "*.log" 2>/dev/null | head -10
#1776561280
curl -v "https://dimark.co/supercerebro/api/proposals.php?action=list&client_id=6" 2>&1 | tail -20
#1776561148
php -l /home/dimark93/public_html/supercerebro/api/proposals.php
#1776561163
tail -50 /home/dimark93/public_html/supercerebro/logs/proposal_error.log
#1776561178
curl -s -o /dev/null -w "%{http_code}" "https://dimark.co/supercerebro/api/proposals.php?action=list&client_id=6"
#1776561203
Ejecuta esto:
#1776561203
```bash
php /home/dimark93/public_html/supercerebro/api/proposals.php 2>&1 | head -20
```php /home/dimark93/public_html/supercerebro/api/proposals.php 2>&1 | head -20
#1776561296
curl -v "https://dimark.co/supercerebro/api/proposals.php?action=list&client_id=6" 2>&1 | tail -20
#1776561556
curl -I "https://dimark.co/supercerebro/api/proposals.php?action=upload_brief" -X POST 2>&1 | head -10
#1776561691
php -r "echo ini_get('upload_max_filesize') . ' / ' . ini_get('post_max_size');"
#1776561945
grep -n "showProposalForm" /home/dimark93/public_html/supercerebro/index.php | head -5
#1776561963
sed -n '3014,3040p' /home/dimark93/public_html/supercerebro/index.php
#1776561989
sed -n '3010,3020p' /home/dimark93/public_html/supercerebro/index.php
#1776562008
sed -i '3014,3018d' /home/dimark93/public_html/supercerebro/index.php
#1776562030
sed -n '3010,3020p' /home/dimark93/public_html/supercerebro/index.php
#1776562099
php -l /home/dimark93/public_html/supercerebro/api/proposals.php && echo "SYNTAX OK"
#1776562115
php -d display_errors=1 -d error_reporting=E_ALL /home/dimark93/public_html/supercerebro/api/proposals.php 2>&1 | head -20
#1776562133
grep -i "proposals\|upload_brief\|500" /usr/local/apache/logs/error_log 2>/dev/null | tail -10
#1776562155
ls -la /home/dimark93/public_html/supercerebro/api/proposals.php
#1776562225
grep -n "require_once\|include" /home/dimark93/public_html/supercerebro/api/proposals.php | head -10
#1776562243
cd /home/dimark93/public_html/supercerebro && php -d display_errors=1 -r "
define('STDIN', fopen('php://stdin','r'));
\$_POST['client_id'] = 6;
\$_SERVER['REQUEST_METHOD'] = 'POST';
require 'api/proposals.php';
" 2>&1 | head -30
#1776562293
ls -la /home/dimark93/public_html/supercerebro/uploads/
#1776562328
head -20 /home/dimark93/public_html/supercerebro/auth.php
#1776562467
currentClient
#1776562590
AA
#1776562592
grep -n "ZipArchive\|read_docx\|pdftotext" /home/dimark93/public_html/supercerebro/api/proposals.php | head -10
#1776562620
php -r "echo class_exists('ZipArchive') ? 'ZipArchive OK' : 'ZipArchive NO'; echo PHP_EOL; echo function_exists('exec') ? 'exec OK' : 'exec DISABLED'; echo PHP_EOL;"
#1776562639
sed -n '430,470p' /home/dimark93/public_html/supercerebro/api/proposals.php
#1776562657
El código del servidor se ve bien. El 500 debe estar en otra parte del archivo. Ejecuta:
#1776562657
```bash
php -d display_errors=1 -d error_reporting=32767 -r "
error_reporting(32767);
ini_set('display_errors',1);
\$_SERVER['HTTP_HOST']='dimark.co';
\$_SERVER['REQUEST_METHOD']='POST';
\$_POST['client_id']=6;
chdir('/home/dimark93/public_html/supercerebro');
require 'api/proposals.php';
" 2>&1 | grep -v "Warning\|Constant\|header\|session\|ini_set" | head -20
```cd /home/dimark93/public_html/supercerebro && php -d display_errors=1 -r "\$_SERVER['REQUEST_METHOD']='POST';\$_POST['client_id']=6;chdir('/home/dimark93/public_html/supercerebro');require 'api/proposals.php';" 2>&1 | grep -iv "warning\|header\|session\|ini_set\|constant" | head -20
#1776562684
cd /home/dimark93/public_html/supercerebro && php -d display_errors=1 -r "\$_SERVER['REQUEST_METHOD']='POST';\$_POST['client_id']=6;chdir('/home/dimark93/public_html/supercerebro');require 'api/proposals.php';" 2>&1 | grep -iv "warning\|header\|session\|ini_set\|constant" | head -20
#1776562728
wc -l /home/dimark93/public_html/supercerebro/api/proposals.php
#1776562756
cp /home/dimark93/public_html/supercerebro/api/proposals.php /home/dimark93/public_html/supercerebro/api/proposals.php.bak && wc -l /home/dimark93/public_html/supercerebro/api/proposals.php.bak
#1776563136
which pdftotext || echo "NO INSTALADO"
#1776563156
yum install poppler-utils -y 2>&1 | tail -5
#1776563531
document.getElementById('prop-brief-hidden').value.substring(0, 200)
#1776611228
tail -20 /usr/local/apache/logs/error_log | grep -i "dimark\|proposals\|supercerebro"
#1776611213
El resultado es `undefined` — el servidor no está respondiendo nada. Eso es un 500 silencioso.
#1776611213
Ejecuta en SSH:
#1776611213
```bash
tail -20 /usr/local/apache/logs/error_log | grep -i "dimark\|proposals\|supercerebro"
```tail -20 /usr/local/apache/logs/error_log | grep -i "dimark\|proposals\|supercerebro"
#1776611213
El resultado es `undefined` — el servidor no está respondiendo nada. Eso es un 500 silencioso.
#1776611213
Ejecuta en SSH:
#1776611213
```bash
tail -20 /usr/local/apache/logs/error_log | grep -i "dimark\|proposals\|supercerebro"
```tail -20 /usr/local/apache/logs/error_log | grep -i "dimark\|proposals\|supercerebro"
#1776611280
grep -n "upload_brief" /home/dimark93/public_html/supercerebro/api/proposals.php
#1776611236
tail -20 /usr/local/apache/logs/error_log | grep -i "dimark\|proposals\|supercerebro"
#1776611255
grep -c "upload_brief" /home/dimark93/public_html/supercerebro/api/proposals.php
#1776611272
Solo 1 ocurrencia — está bien. Ejecuta:
#1776611272
```bash
grep -n "upload_brief" /home/dimark93/public_html/supercerebro/api/proposals.php
```grep -n "upload_brief" /home/dimark93/public_html/supercerebro/api/proposals.php
#1776611285
grep -n "upload_brief" /home/dimark93/public_html/supercerebro/api/proposals.php
#1776611306
sed -n '400,430p' /home/dimark93/public_html/supercerebro/api/proposals.php
#1776611355
sed -n '1,10p' /home/dimark93/public_html/supercerebro/api/proposals.php
#1776630402
grep -c "img_hero\|images_context_labeled\|PROHIBIDO usar otras" /home/dimark93/public_html/supercerebro/api/proposals.php
#1776630465
grep -c "img_hero\|images_context_labeled" /home/dimark93/public_html/supercerebro/api/proposals.php
#1776632392
grep -c "1518770660439" /home/dimark93/public_html/supercerebro/api/proposals.php
#1776633133
php -l /home/dimark93/public_html/supercerebro/api/proposals.php
#1776633164
cp /home/dimark93/public_html/supercerebro/api/proposals.php.bak /home/dimark93/public_html/supercerebro/api/proposals.php
#1776643939
<?php
#1776643939
// api/proposals.php v3 — Limpio y funcional
#1776643939
header('Content-Type: application/json');
#1776643939
require_once __DIR__ . '/../config.php';
#1776643939
require_once __DIR__ . '/../db.php';
#1776643939
require_once __DIR__ . '/../auth.php';
#1776643939
dm_require_login();
#1776643939
$input  = json_decode(file_get_contents('php://input'), true) ?? [];
#1776643939
$action = $_GET['action'] ?? $input['action'] ?? '';
#1776643939
// ── Helpers ───────────────────────────────────────────────────────────────────
#1776643939
function generate_token(): string {
#1776643939
    return bin2hex(random_bytes(16));
#1776643939
}
#1776643939
function call_claude(string $prompt, int $max_tokens = 8000): string {
#1776643939
    $api_key = defined('CLAUDE_API_KEY') ? CLAUDE_API_KEY : '';
#1776643939
    if (;api_key) return '';
#1776643939
    $ch = curl_init('https://api.anthropic.com/v1/messages');
#1776643939
    curl_setopt_array($ch, [
#1776643939
        CURLOPT_RETURNTRANSFER => true,
#1776643939
        CURLOPT_POST           => true,
#1776643939
        CURLOPT_HTTPHEADER     => [
#1776643939
            'Content-Type: application/json',
#1776643939
            'x-api-key: ' . $api_key,
#1776643939
            'anthropic-version: 2023-06-01',
#1776643939
        ],
#1776643939
        CURLOPT_POSTFIELDS => json_encode([
#1776643939
            'model'      => 'claude-sonnet-4-20250514',
#1776643939
            'max_tokens' => $max_tokens,
#1776643939
            'messages'   => [['role' => 'user', 'content' => $prompt]],
#1776643939
        ]),
#1776643939
        CURLOPT_TIMEOUT    => 120,
#1776643939
        CURLOPT_SSL_VERIFYPEER => false,
#1776643939
    ]);
#1776643939
    $response = curl_exec($ch);
#1776643939
    curl_close($ch);
#1776643939
    $r = json_decode($response, true);
#1776643939
        $log = __DIR__ . '/../logs/proposal_error.log';
#1776643939
        file_put_contents($log, date('Y-m-d H:i:s') . ' ' . json_encode($r['error']) . "\n", FILE_APPEND);
#1776643939
        if (strpos($r['error']['message'] ?? '', 'credit balance') !== false) return '__CREDIT_ERROR__';
#1776643939
    }
#1776643939
    return $r['content'][0]['text'] ?? '';
#1776643939
}
#1776643939
function extract_colors_from_image(string $filepath): array {
#1776643939
    $ext = strtolower(pathinfo($filepath, PATHINFO_EXTENSION));
#1776643939
    $img = null;
#1776643939
    try {
#1776643939
        switch($ext) {
#1776643939
            case 'jpg': case 'jpeg': $img = imagecreatefromjpeg($filepath); break;
#1776643939
            case 'png':  $img = imagecreatefrompng($filepath); break;
#1776643939
            case 'gif':  $img = imagecreatefromgif($filepath); break;
#1776643939
            case 'webp': $img = imagecreatefromwebp($filepath); break;
#1776643939
            default: return [];
#1776643939
        }
#1776643939
    } catch(Exception $e) { return []; }
#1776643939
    if (}img) return [];
#1776643939
    $small = imagecreatetruecolor(50, 50);
#1776643939
    imagecopyresampled($small, $img, 0, 0, 0, 0, 50, 50, imagesx($img), imagesy($img));
#1776643939
    imagedestroy($img);
#1776643939
    $colors = [];
#1776643939
    for ($x = 0; $x < 50; $x++) {
#1776643939
        for ($y = 0; $y < 50; $y++) {
#1776643939
            $rgb = imagecolorat($small, $x, $y);
#1776643939
            $r = ($rgb >> 16) & 0xFF;
#1776643939
            $g = ($rgb >> 8)  & 0xFF;
#1776643939
            $b = $rgb & 0xFF;
#1776643939
            if (($r > 240 && $g > 240 && $b > 240) || ($r < 15 && $g < 15 && $b < 15)) continue;
#1776643939
            $key = (intval($r/32)*32) . ',' . (intval($g/32)*32) . ',' . (intval($b/32)*32);
#1776643939
            $colors[$key] = ($colors[$key] ?? 0) + 1;
#1776643939
        }
#1776643939
    }
#1776643939
    imagedestroy($small);
#1776643939
    arsort($colors);
#1776643939
    $hex = [];
#1776643939
    foreach (array_slice(array_keys($colors), 0, 4) as $key) {
#1776643939
        list($r, $g, $b) = explode(',', $key);
#1776643939
        $hex[] = sprintf('#%02x%02x%02x', (int)$r, (int)$g, (int)$b);
#1776643939
    }
#1776643939
    return $hex;
#1776643939
}
#1776643939
function read_docx(string $filepath): string {
#1776643939
    $zip = new ZipArchive();
#1776643939
    if ($zip->open($filepath) !== true) return '';
#1776643939
    $xml = $zip->getFromName('word/document.xml');
#1776643939
    $zip->close();
#1776643939
    if (;xml) return '';
#1776643939
    $xml = str_replace('</w:r>', ' ', $xml);
#1776643939
    $xml = str_replace('</w:p>', "\n", $xml);
#1776643939
    $xml = strip_tags($xml);
#1776643939
    return trim(preg_replace('/[ \t]+/', ' ', $xml));
#1776643939
}
#1776643939
function upload_file(string $field, string $dir_id): string {
#1776643939
    if (empty($_FILES[$field]['tmp_name'])) return '';
#1776643939
    $ext = strtolower(pathinfo($_FILES[$field]['name'], PATHINFO_EXTENSION));
#1776643939
    $allowed = ['jpg','jpeg','png','gif','webp','pdf','svg'];
#1776643939
    $dir = __DIR__ . '/../uploads/proposals/' . $dir_id . '/';
#1776643939
    $name = uniqid() . '.' . $ext;
#1776643939
    if (move_uploaded_file($_FILES[$field]['tmp_name'], $dir . $name)) {
#1776643939
        return 'uploads/proposals/' . $dir_id . '/' . $name;
#1776643939
    }
#1776643939
    return '';
#1776643939
}
#1776643939
function get_images_for_industry(string $text): string {
#1776643939
    $t = strtolower($text);
#1776643939
    $map = [
#1776643939
        'aviacion|helicoptero|vuelo|aereo|charter|avion|air|aviation' => [
#1776643939
            'https://images.unsplash.com/photo-1436491865332-7a61a109cc05?w=1600&q=80',
#1776643939
            'https://images.unsplash.com/photo-1569767013863-aa6ef73a6ef5?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1474302770737-173ee21bab63?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1464037866556-6812c9d1c72e?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1488646953014-85cb44e25828?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1469474968028-56623f02e42e?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1531366936337-7c912a4589a7?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1501854140801-50d01698950b?w=1200&q=80',
#1776643939
        ],
#1776643939
        'dental|dent|odont|salud|clinica|medic|health' => [
#1776643939
            'https://images.unsplash.com/photo-1559757148-5c350d0d3c56?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1606811841689-23dfddce3e0f?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1576091160399-112ba8d25d1d?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1612349317150-e413f6a5b16d?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1588776814546-ec7e6b7d94af?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1579684385127-1ef15d508118?w=1200&q=80',
#1776643939
        ],
#1776643939
        'restaurante|food|comida|chef|gastronomia|cafe|bar' => [
#1776643939
            'https://images.unsplash.com/photo-1414235077428-338989a2e8c0?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1555396273-367ea4eb4db5?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1504674900247-0877df9cc836?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1517248135467-4c7edcad34c4?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1565299624946-b28f40a0ae38?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1482049016688-2d3e1b311543?w=1200&q=80',
#1776643939
        ],
#1776643939
        'hotel|resort|hosped|alojam|suite|turismo' => [
#1776643939
            'https://images.unsplash.com/photo-1566073771259-6a8506099945?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1582719508461-905c673771fd?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1542314831-068cd1dbfeeb?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1571003123894-1f0594d2b5d9?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1520250497591-112f2f40a3f4?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1445019980597-93fa8acb246c?w=1200&q=80',
#1776643939
        ],
#1776643939
        'inmob|real.estate|propiedad|apartamento|casa|vivienda' => [
#1776643939
            'https://images.unsplash.com/photo-1560518883-ce09059eeffa?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1613977257363-707ba9348227?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1580587771525-78b9dba3b914?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1570129477492-45c003edd2be?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1523217582562-09d0def993a6?w=1200&q=80',
#1776643939
        ],
#1776643939
        'fitness|gym|deport|sport|ejerc' => [
#1776643939
            'https://images.unsplash.com/photo-1534438327276-14e5300c3a48?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1571019614242-c5c5dee9f50b?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1583454110551-21f2fa2afe61?w=1200&q=80',
#1776643939
            'https://images.unsplash.com/photo-1549060279-7e168fcee0c2?w=1200&q=80',
#1776643939
        ],
#1776643939
    ];
#1776643939
    foreach ($map as $pattern => $urls) {
#1776643939
        if (preg_match("/$pattern/i", $t)) {
#1776643939
            return implode("\n", $urls);
#1776643939
        }
#1776643939
    }
#1776643939
    // Fallback genérico
#1776643939
    return implode("\n", [
#1776643939
        'https://images.unsplash.com/photo-1497366216548-37526070297c?w=1200&q=80',
#1776643939
        'https://images.unsplash.com/photo-1497366754035-f200581399c4?w=1200&q=80',
#1776643939
        'https://images.unsplash.com/photo-1552664730-d307ca884978?w=1200&q=80',
#1776643939
        'https://images.unsplash.com/photo-1559136555-9303baea8ebd?w=1200&q=80',
#1776643939
        'https://images.unsplash.com/photo-1522202176988-66273c2fd55f?w=1200&q=80',
#1776643939
        'https://images.unsplash.com/photo-1600880292203-757bb62b4baf?w=1200&q=80',
#1776643939
    ]);
#1776643939
}
#1776643939
// ── Switch ────────────────────────────────────────────────────────────────────
#1776643939
switch ($action) {
#1776643939
    case 'list':         $client_id = (int)($_GET['client_id'] ?? 0);
#1776643939
        if (;client_id) { echo json_encode(['ok'=>false,'error'=>'client_id requerido']); exit; }
#1776643939
        $stmt = $pdo->prepare("SELECT id,project_name,status,client_vote,token,created_at FROM dm_proposals WHERE client_id=? ORDER BY created_at DESC");
#1776643939
        $stmt->execute([$client_id]);
#1776643939
        echo json_encode(['ok'=>true,'proposals'=>$stmt->fetchAll(PDO::FETCH_ASSOC)]);
#1776643939
        break;
#1776643939
    case 'get':         $id = (int)($_GET['id'] ?? 0);
#1776643939
        $stmt = $pdo->prepare("SELECT * FROM dm_proposals WHERE id=?");
#1776643939
        $stmt->execute([$id]);
#1776643939
        $p = $stmt->fetch(PDO::FETCH_ASSOC);
#1776643939
        if (;p) { echo json_encode(['ok'=>false,'error'=>'No encontrada']); exit; }
#1776643939
        echo json_encode(['ok'=>true,'proposal'=>$p]);
#1776643939
        break;
#1776643939
    case 'save':         $client_id    = (int)($input['client_id'] ?? 0);
#1776643939
        $project_name = trim($input['project_name'] ?? '');
#1776643939
        if (;client_id || ;project_name) { echo json_encode(['ok'=>false,'error'=>'Faltan campos']); exit; }
#1776643939
        $id = (int)($input['id'] ?? 0);
#1776643939
        $data = [
#1776643939
            'client_id'       => $client_id,
#1776643939
            'project_name'    => $project_name,
#1776643939
            'brief'           => $input['brief'] ?? '',
#1776643939
            'structure'       => $input['structure'] ?? '',
#1776643939
            'references_urls' => $input['references_urls'] ?? '',
#1776643939
            'brand_colors'    => $input['brand_colors'] ?? '',
#1776643939
            'brand_fonts'     => $input['brand_fonts'] ?? '',
#1776643939
            'extra_notes'     => $input['extra_notes'] ?? '',
#1776643939
            'replicate_url'   => $input['replicate_url'] ?? '',
#1776643939
            'created_by'      => dm_user()['id'],
#1776643939
        ];
#1776643939
        if ($id) {
#1776643939
            $sets = implode(',', array_map(fn($k) => "$k=:$k", array_keys($data)));
#1776643939
            $data['id'] = $id;
#1776643939
            $pdo->prepare("UPDATE dm_proposals SET $sets WHERE id=:id")->execute($data);
#1776643939
        } else {
#1776643939
            $data['token'] = generate_token();
#1776643939
            $cols = implode(',', array_keys($data));
#1776643939
            $vals = ':' . implode(',:', array_keys($data));
#1776643939
            $pdo->prepare("INSERT INTO dm_proposals ($cols) VALUES ($vals)")->execute($data);
#1776643939
            $id = $pdo->lastInsertId();
#1776643939
        }
#1776643939
        echo json_encode(['ok'=>true,'id'=>$id]);
#1776643939
        break;
#1776643939
    case 'upload':         $client_id = (int)($_POST['client_id'] ?? 0);
#1776643939
        $prop_id   = (int)($_POST['proposal_id'] ?? 0);
#1776643939
        $type      = $_POST['type'] ?? 'logo';
#1776643939
        $dir_id    = $client_id ?: 'tmp';
#1776643939
        $field     = in_array($type, ['brand_manual']) ? 'brand_manual' : 'logo';
#1776643939
        $path      = upload_file($field, $dir_id);
#1776643939
        if (;path) { echo json_encode(['ok'=>false,'error'=>'Error al subir']); exit; }
#1776643939
        $col = $type === 'brand_manual' ? 'brand_manual_path' : 'logo_path';
#1776643939
        if ($prop_id) {
#1776643939
            $pdo->prepare("UPDATE dm_proposals SET $col=? WHERE id=?")->execute([$path, $prop_id]);
#1776643939
        }
#1776643939
        $colors = [];
#1776643939
        if ($type === 'logo') {
#1776643939
            $colors = extract_colors_from_image(__DIR__ . '/../' . $path);
#1776643939
                $pdo->prepare("UPDATE dm_proposals SET brand_colors=? WHERE id=?")->execute([implode(', ', $colors), $prop_id]);
#1776643939
            }
#1776643939
        }
#1776643939
        echo json_encode(['ok'=>true,'path'=>$path,'url'=>'/'.$path,'colors'=>$colors]);
#1776643939
        break;
#1776643939
    case 'upload_brief':         $client_id = (int)($_POST['client_id'] ?? 0);
#1776643939
        if (;client_id) { echo json_encode(['ok'=>false,'error'=>'client_id requerido']); exit; }
#1776643939
        if (empty($_FILES['brief_file']['tmp_name'])) { echo json_encode(['ok'=>false,'error'=>'No se recibio archivo']); exit; }
#1776643939
        $ext = strtolower(pathinfo($_FILES['brief_file']['name'], PATHINFO_EXTENSION));
#1776643939
        $dir = __DIR__ . '/../uploads/briefs/' . $client_id . '/';
#1776643939
        $filepath = $dir . uniqid() . '.' . $ext;
#1776643939
            echo json_encode(['ok'=>false,'error'=>'Error al guardar']); exit;
#1776643939
        }
#1776643939
        $text = '';
#1776643939
        if ($ext === 'docx') {
#1776643939
            $text = read_docx($filepath);
#1776643939
        } elseif ($ext === 'txt') {
#1776643939
            $text = file_get_contents($filepath);
#1776643939
        } elseif ($ext === 'pdf') {
#1776643939
            $tmp = sys_get_temp_dir() . '/' . uniqid() . '.txt';
#1776643939
            @exec('pdftotext ' . escapeshellarg($filepath) . ' ' . escapeshellarg($tmp) . ' 2>/dev/null');
#1776643939
            if (file_exists($tmp) && filesize($tmp) > 10) {
#1776643939
                $text = trim(file_get_contents($tmp));
#1776643939
                @unlink($tmp);
#1776643939
            }
#1776643939
            if (strlen($text) < 50) {
#1776643939
                $raw = file_get_contents($filepath);
#1776643939
                preg_match_all('/\(([^)]{1,200})\)\s*Tj/', $raw, $m);
#1776643939
            }
#1776643939
        }
#1776643939
        $urls = [];
#1776643939
        preg_match_all('/https?:\/\/[^\s\)\]"\'<>]+/', $text, $um);
#1776643939
        $urls = array_unique($um[0] ?? []);
#1776643939
        echo json_encode(['ok'=>true,'text'=>$text,'filename'=>basename($filepath),'urls'=>array_values($urls)]);
#1776643939
        break;
#1776643939
    case 'generate':         $id = (int)($input['id'] ?? 0);
#1776643939
        if (;id) { echo json_encode(['ok'=>false,'error'=>'id requerido']); exit; }
#1776643939
        $stmt = $pdo->prepare("SELECT * FROM dm_proposals WHERE id=?");
#1776643939
        $stmt->execute([$id]);
#1776643939
        $p = $stmt->fetch(PDO::FETCH_ASSOC);
#1776643939
        if (;p) { echo json_encode(['ok'=>false,'error'=>'No encontrada']); exit; }
#1776643939
        $style = (int)($input['style'] ?? 1);
#1776643939
        // Colores del cliente
#1776643939
        $colors_raw = trim($p['brand_colors'] ?? '');
#1776643939
        $color_list = array_filter(array_map('trim', explode(',', $colors_raw)));
#1776643939
        $c1 = $color_list[0] ?? '#1a1a2e';
#1776643939
        $c2 = $color_list[1] ?? '#E8272A';
#1776643939
        $c3 = $color_list[2] ?? '#ffffff';
#1776643939
        // Logo
#1776643939
        $logo_url = '';
#1776643939
            $base = (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . ($_SERVER['HTTP_HOST'] ?? 'dimark.co');
#1776643939
            $logo_url = $base . '/supercerebro/' . $p['logo_path'];
#1776643939
        }
#1776643939
        $logo_tag = $logo_url
#1776643939
            ? '<img src="' . $logo_url . '" alt="Logo" style="height:50px;object-fit:contain;max-width:180px">'
#1776643939
            : '<span style="font-size:20px;font-weight:800">' . htmlspecialchars($p['project_name']) . '</span>';
#1776643939
        // Imágenes del sector
#1776643939
        $industry_text = $p['project_name'] . ' ' . $p['brief'] . ' ' . $p['extra_notes'];
#1776643939
        $img_urls = get_images_for_industry($industry_text);
#1776643939
        $img_list = array_values(array_filter(explode("\n", $img_urls)));
#1776643939
        // Referentes
#1776643939
        $refs = trim($p['references_urls'] ?? '');
#1776643939
        // Layouts únicos por estilo
#1776643939
        $layouts = [
#1776643939
            1 => [
#1776643939
                'name' => 'Moderno Bold',
#1776643939
                'desc' => 'Oscuro, cinematico. Fondo #0a0a0a, tipografia gigante, acentos de color de marca.',
#1776643939
                'instructions' => '
HEADER: fixed, transparent→oscuro al scroll, logo izq, nav der uppercase
HERO: 100vh, background-image fullscreen, overlay oscuro, H1 clamp(72px,12vw,140px) bold blanco
SERVICIOS: grid 3 cols, cards oscuras con imagen top 220px, hover lift+shadow de marca
STATS: fila 4 numeros grandes, fondo gradient de marca
NOSOTROS: 2 cols, imagen izq con clip-path diagonal, texto der
TESTIMONIOS: carousel horizontal, fondo #111
GALERIA: CSS columns masonry, hover scale+overlay
CONTACTO: fondo oscuro, inputs solo border-bottom
FOOTER: 4 cols, fondo #050505, separador gradient'
#1776643939
            ],
#1776643939
            2 => [
#1776643939
                'name' => 'Elegante Profesional',
#1776643939
                'desc' => 'Claro, minimalista europeo. Fondo blanco, tipografia serif, mucho whitespace.',
#1776643939
                'instructions' => '
HEADER: fixed, fondo blanco, LOGO CENTRADO, nav simetrica ambos lados, border-bottom sutil
HERO: 100vh SPLIT 45/55 — izq fondo color marca texto blanco, der imagen sin overlay
SERVICIOS: lista vertical con numero grande serif izq, divisor 1px, titulo+desc+flecha
PARALLAX: imagen fullwidth 60vh background-attachment:fixed
NOSOTROS: timeline vertical, años en color marca, linea vertical
TESTIMONIOS: cita gigante centrada con comillas decorativas, auto-rotate 5s
GALERIA: grid 4 cols, hover overlay color marca opacity 0.7
CONTACTO: 2 cols — info izq, form der
FOOTER: fondo color marca, logo centrado blanco, links centrados'
#1776643939
            ],
#1776643939
            3 => [
#1776643939
                'name' => 'Fresco Dinamico',
#1776643939
                'desc' => 'Gradientes vibrantes, shapes, energia startup moderna.',
#1776643939
                'instructions' => '
HEADER: fondo color marca SOLIDO siempre, logo blanco, nav blanca, boton CTA outline
HERO: gradient animado, 3-4 blobs absolutos blur+float, texto izq, badge pill animado
SERVICIOS: cards border-radius 24px, iconos gradient, shadow colorido, hover lift
STATS: gradient fondo animado, cards glassmorphism, iconos blancos
NOSOTROS: imagen redondeada border-radius 32px, floating-cards con stats encima
TESTIMONIOS: grid 3 cols, estrellas doradas, foto redonda
GALERIA: 3x2 grid border-radius 16px, hover scale+overlay gradient
CONTACTO: fondo gradient, form en card blanca flotante
FOOTER: gradient fondo, shapes decorativos, links en pills glassmorphism'
#1776643939
            ],
#1776643939
        ];
#1776643939
        $s = $layouts[$style];
#1776643939
        $prompt = <<<PROMPT
#1776643939
Eres el mejor diseñador web del mundo nivel Awwwards 2025. Crea un homepage ESPECTACULAR y ÚNICO.
#1776643939
CLIENTE: {$p['project_name']}
#1776643939
ESTILO: {$s['name']} — {$s['desc']}
#1776643939
BRIEF COMPLETO:
#1776643939
{$p['brief']}
#1776643939
{$p['structure']}
#1776643939
ADN DE MARCA:
#1776643939
{$p['extra_notes']}
#1776643939
REFERENTES (inspírate en su nivel):
#1776643939
{$refs}
#1776643939
COLORES DE MARCA (OBLIGATORIO usar solo estos):
#1776643939
Principal: {$c1}
#1776643939
Acento: {$c2}
#1776643939
Claro: {$c3}
#1776643939
Define en :root: --primary:{$c1}; --accent:{$c2}; --light:{$c3};
#1776643939
USA SOLO var(--primary) y var(--accent) — NUNCA #007bff ni otros colores genéricos.
#1776643939
LAYOUT DE ESTA PROPUESTA (seguir exactamente):
#1776643939
{$s['instructions']}
#1776643939
IMÁGENES (OBLIGATORIO — copiar estas URLs exactas):
#1776643939
img1: {($img_list[0] ?? '')}
#1776643939
img2: {($img_list[1] ?? '')}
#1776643939
img3: {($img_list[2] ?? '')}
#1776643939
img4: {($img_list[3] ?? '')}
#1776643939
img5: {($img_list[4] ?? '')}
#1776643939
img6: {($img_list[5] ?? '')}
#1776643939
img7: {($img_list[6] ?? '')}
#1776643939
img8: {($img_list[7] ?? '')}
#1776643939
Hero = img1 como background-image. Servicios = img2,img3,img4. Nosotros = img5. Galería = img3,img4,img5,img6,img7,img8.
#1776643939
HEADER (obligatorio):
#1776643939
Logo: {$logo_tag}
#1776643939
Sticky. Cambiar fondo al scroll.
#1776643939
FOOTER (obligatorio — SIEMPRE incluir <footer>):
#1776643939
Logo: {$logo_tag}
#1776643939
4 columnas: descripción, servicios, contacto, redes.
#1776643939
Terminar con: <div style="text-align:center;padding:12px;background:rgba(0,0,0,0.3);font-size:11px;opacity:0.7">Powered by <a href="https://dimark.co" target="_blank" style="color:inherit;font-weight:700;text-decoration:none">DIMARK</a></div>
#1776643939
EFECTOS OBLIGATORIOS:
#1776643939
- @keyframes gradientShift, fadeInUp, float, pulseGlow en <style>
#1776643939
- Hover cards: translateY(-12px) + box-shadow con var(--primary)
#1776643939
- Gradient text en H1: background-clip:text con var(--primary) y var(--accent)
#1776643939
- Cursor personalizado + scroll progress bar en <script>
#1776643939
- IntersectionObserver para reveal animations
#1776643939
- Stagger delay en cards: nth-child con animation-delay
#1776643939
TÉCNICO:
#1776643939
- HTML completo con DOCTYPE
#1776643939
- Google Fonts en <head>
#1776643939
- CSS en <style>, JS en <script> al final del body
#1776643939
- Responsive 768px y 480px
#1776643939
- Contenido REAL del negocio, no Lorem ipsum
#1776643939
- Testimonios: mínimo 3
#1776643939
- Formulario completo en contacto
#1776643939
PROMPT;
#1776643939
        $pdo->prepare("UPDATE dm_proposals SET status='generating' WHERE id=?")->execute([$id]);
#1776643939
        set_time_limit(120);
#1776643939
        $html = call_claude($prompt, 8000);
#1776643939
        if (empty($html) || $html === '__CREDIT_ERROR__') {
#1776643939
            $pdo->prepare("UPDATE dm_proposals SET status='ready' WHERE id=?")->execute([$id]);
#1776643939
            $log = __DIR__ . '/../logs/proposal_error.log';
#1776643939
            file_put_contents($log, date('Y-m-d H:i:s') . " Style {$style} error\n", FILE_APPEND);
#1776643939
            $err = ($html === '__CREDIT_ERROR__') ? 'SIN_CREDITOS' : 'Error generando';
#1776643939
            echo json_encode(['ok'=>false,'error'=>$err]); exit;
#1776643939
        }
#1776643939
        // Limpiar markdown si Claude lo agrega
#1776643939
        $html = preg_replace('/^```html\s*/i', '', trim($html));
#1776643939
        $html = preg_replace('/```\s*$/', '', $html);
#1776643939
        // Garantizar footer DIMARK si Claude no lo puso
#1776643939
        if (stripos($html, 'dimark.co') === false) {
#1776643939
            $footer_dimark = '<div style="text-align:center;padding:12px;background:rgba(0,0,0,0.3);font-size:11px;opacity:0.7">Powered by <a href="https://dimark.co" target="_blank" style="color:inherit;font-weight:700;text-decoration:none">DIMARK</a></div>';
#1776643939
            $html = str_ireplace('</body>', $footer_dimark . '</body>', $html);
#1776643939
        }
#1776643939
        $col      = "proposal_{$style}";
#1776643939
        $name_col = "proposal_{$style}_name";
#1776643939
        $pdo->prepare("UPDATE dm_proposals SET $col=?, $name_col=?, status='ready' WHERE id=?")
#1776643939
            ->execute([$html, $s['name'], $id]);
#1776643939
        echo json_encode(['ok'=>true,'style'=>$style,'name'=>$s['name'],'html'=>$html]);
#1776643939
        break;
#1776643939
    case 'send':         $id = (int)($input['id'] ?? 0);
#1776643939
        if (;id) { echo json_encode(['ok'=>false,'error'=>'id requerido']); exit; }
#1776643939
        $stmt = $pdo->prepare("SELECT token,project_name FROM dm_proposals WHERE id=?");
#1776643939
        $stmt->execute([$id]);
#1776643939
        $p = $stmt->fetch(PDO::FETCH_ASSOC);
#1776643939
        if (;p) { echo json_encode(['ok'=>false,'error'=>'No encontrada']); exit; }
#1776643939
        $pdo->prepare("UPDATE dm_proposals SET status='sent' WHERE id=?")->execute([$id]);
#1776643939
        $link = (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/supercerebro/propuesta.php?t=' . $p['token'];
#1776643939
        echo json_encode(['ok'=>true,'link'=>$link]);
#1776643939
        break;
#1776643939
    case 'vote':         $token = $input['token'] ?? '';
#1776643939
        $vote  = (int)($input['vote'] ?? 0);
#1776643939
        $notes = trim($input['comments'] ?? '');
#1776643939
        if (;token || ;vote) { echo json_encode(['ok'=>false,'error'=>'Faltan datos']); exit; }
#1776643939
        $stmt = $pdo->prepare("SELECT id,project_name,client_comments FROM dm_proposals WHERE token=?");
#1776643939
        $stmt->execute([$token]);
#1776643939
        $prop = $stmt->fetch(PDO::FETCH_ASSOC);
#1776643939
        if (;prop) { echo json_encode(['ok'=>false,'error'=>'Token inválido']); exit; }
#1776643939
        $comments = json_decode($prop['client_comments'] ?? '[]', true) ?: [];
#1776643939
            $comments[] = ['section'=>'Voto final','comment'=>$notes,'style'=>$vote,'date'=>date('Y-m-d H:i:s')];
#1776643939
        }
#1776643939
        $pdo->prepare("UPDATE dm_proposals SET client_vote=?,client_comments=?,status='voted' WHERE token=?")
#1776643939
            ->execute([$vote, json_encode($comments), $token]);
#1776643939
        // Email
#1776643939
        $to = defined('DIMARK_EMAIL') ? DIMARK_EMAIL : 'info@dimark.co';
#1776643939
        $subject = "Cliente votó: {$prop['project_name']} — Propuesta {$vote}";
#1776643939
        $body = "El cliente eligió Propuesta {$vote}.\nNotas: {$notes}";
#1776643939
        @mail($to, $subject, $body, "From: noreply@dimark.co\r\n");
#1776643939
        echo json_encode(['ok'=>true]);
#1776643939
        break;
#1776643939
    case 'vote_comment':         $token   = $input['token'] ?? '';
#1776643939
        $section = trim($input['section'] ?? 'General');
#1776643939
        $comment = trim($input['comment'] ?? '');
#1776643939
        if (;token || ;comment) { echo json_encode(['ok'=>false,'error'=>'Faltan datos']); exit; }
#1776643939
        $stmt = $pdo->prepare("SELECT id,client_comments FROM dm_proposals WHERE token=?");
#1776643939
        $stmt->execute([$token]);
#1776643939
        $prop = $stmt->fetch(PDO::FETCH_ASSOC);
#1776643939
        if (;prop) { echo json_encode(['ok'=>false,'error'=>'Token inválido']); exit; }
#1776643939
        $comments = json_decode($prop['client_comments'] ?? '[]', true) ?: [];
#1776643939
        $comments[] = ['section'=>$section,'comment'=>$comment,'date'=>date('Y-m-d H:i:s')];
#1776643939
        $pdo->prepare("UPDATE dm_proposals SET client_comments=? WHERE id=?")->execute([json_encode($comments), $prop['id']]);
#1776643939
        echo json_encode(['ok'=>true]);
#1776643939
        break;
#1776643939
    case 'get_comments_public':         $token = $_GET['token'] ?? '';
#1776643939
        if (;token) { echo json_encode(['ok'=>false,'error'=>'Token inválido']); exit; }
#1776643939
        $stmt = $pdo->prepare("SELECT client_comments,client_vote FROM dm_proposals WHERE token=?");
#1776643939
        $stmt->execute([$token]);
#1776643939
        $row = $stmt->fetch(PDO::FETCH_ASSOC);
#1776643939
        if (;row) { echo json_encode(['ok'=>false,'error'=>'No encontrada']); exit; }
#1776643939
        $comments = json_decode($row['client_comments'] ?? '[]', true) ?: [];
#1776643939
        echo json_encode(['ok'=>true,'comments'=>$comments,'vote'=>$row['client_vote']]);
#1776643939
        break;
#1776643939
    case 'public':         $token = $_GET['token'] ?? '';
#1776643939
        if (;token) { echo json_encode(['ok'=>false,'error'=>'Token inválido']); exit; }
#1776643939
        $stmt = $pdo->prepare("SELECT id,project_name,proposal_1,proposal_2,proposal_3,proposal_1_name,proposal_2_name,proposal_3_name,client_vote,client_comments,status FROM dm_proposals WHERE token=?");
#1776643939
        $stmt->execute([$token]);
#1776643939
        $p = $stmt->fetch(PDO::FETCH_ASSOC);
#1776643939
        if (;p) { echo json_encode(['ok'=>false,'error'=>'No encontrada']); exit; }
#1776643939
        echo json_encode(['ok'=>true,'proposal'=>$p]);
#1776643939
        break;
#1776643939
    case 'save_html':         $id    = (int)($input['id'] ?? 0);
#1776643939
        $style = (int)($input['style'] ?? 0);
#1776643939
        $html  = $input['html'] ?? '';
#1776643939
        if (;id || ;style || empty($html)) { echo json_encode(['ok'=>false,'error'=>'Faltan datos']); exit; }
#1776643939
        $col = "proposal_{$style}";
#1776643939
        $pdo->prepare("UPDATE dm_proposals SET $col=?,updated_at=NOW() WHERE id=?")->execute([$html, $id]);
#1776643939
        echo json_encode(['ok'=>true]);
#1776643939
        break;
#1776643939
    case 'delete':         $id = (int)($input['id'] ?? 0);
#1776643939
        if (;id) { echo json_encode(['ok'=>false,'error'=>'id requerido']); exit; }
#1776643939
        $pdo->prepare("DELETE FROM dm_proposals WHERE id=?")->execute([$id]);
#1776643939
        echo json_encode(['ok'=>true]);
#1776643939
        break;
#1776643939
    default:
#1776643939
        echo json_encode(['ok'=>false,'error'=>"Accion no reconocida: $action"]);
#1776644147
mkdir -p /tu-ruta/supercerebro/uploads/briefs
#1776644149
chmod 755 /tu-ruta/supercerebro/uploads/briefsmkdir -p /tu-ruta/supercerebro/uploads/briefs
#1776644191
chmod 755 /tu-ruta/supercerebro/uploads/briefs
#1776644192
mkdir -p /home/dimark93/supercerebro/uploads/briefs
#1776644192
chmod 755 /home/dimark93/supercerebro/uploads/briefs
#1776644192
mkdir -p /home/dimark93/supercerebro/uploads/proposals
#1776644192
chmod 755 /home/dimark93/supercerebro/uploads/proposals
#1776644192
mkdir -p /home/dimark93/supercerebro/logs
#1776644265
chmod 755 /home/dimark93/supercerebro/logs
#1776644266
curl "https://dimark.co/supercerebro/api/proposals.php?action=list&client_id=6" 2>&1
#1776644286
curl "https://dimark.co/supercerebro/api/proposals.php?action=list&client_id=6"
#1776644325
php /home/dimark93/supercerebro/api/proposals.php 2>&1
#1776644337
php -l /home/dimark93/supercerebro/api/proposals.php
#1776644337
php -l /home/dimark93/supercerebro/db.php
#1776644343
php -l /home/dimark93/supercerebro/config.phpphp -l /home/dimark93/supercerebro/api/proposals.php
#1776644343
php -l /home/dimark93/supercerebro/db.php
#1776644345
php -l /home/dimark93/supercerebro/config.php
#1776644346
php -l /home/dimark93/supercerebro/api/proposals.php
#1776644346
php -l /home/dimark93/supercerebro/db.php
#1776644366
php -l /home/dimark93/supercerebro/config.php
#1776644367
find /home/dimark93 -name "proposals.php" 2>/dev/null
#1776644369
find /home/dimark93 -name "config.php" 2>/dev/null
#1776644370
find /home/dimark93 -name "proposals.php" 2>/dev/null
#1776644371
find /home/dimark93 -name "config.php" 2>/dev/nullfind /home/dimark93 -name "proposals.php" 2>/dev/null
#1776644385
find /home/dimark93 -name "config.php" 2>/dev/null
#1776644387
php -l /home/dimark93/public_html/supercerebro/api/proposals.php
#1776644396
php /home/dimark93/public_html/supercerebro/api/proposals.php 2>&1
#1776644408
php -l /home/dimark93/public_html/supercerebro/api/proposals.php 2>&1
#1776644424
php -l /home/dimark93/public_html/supercerebro/api/proposals.php 2>&1 | head -20
#1776644440
php -d display_errors=1 -d error_reporting=32767 /home/dimark93/public_html/supercerebro/api/proposals.php 2>&1
#1776644460
sed -n '120,135p' /home/dimark93/public_html/supercerebro/api/proposals.php
#1776644509
sed -n '126,130p' /home/dimark93/public_html/supercerebro/api/proposals.php
#1776644516
nano /home/dimark93/public_html/supercerebro/api/proposals.php
#1776644738
sed -n '124,132p' /home/dimark93/public_html/supercerebro/api/proposals.php
#1776644755
sed -i "s/return 'uploads\/proposals\/' \. \$dir_id$/return 'uploads\/proposals\/' . \$dir_id . '\/' . \$name;\n    }\n    return '';\n}/" /home/dimark93/public_html/supercerebro/api/proposals.php
#1776644765
sed -n '124,133p' /home/dimark93/public_html/supercerebro/api/proposals.php
#1776644769
php -l /home/dimark93/public_html/supercerebro/api/proposals.php
#1776644851
curl "https://dimark.co/supercerebro/api/proposals.php?action=list&client_id=6" 2>&1
#1776644879
php -d display_errors=1 -d error_reporting=32767 /home/dimark93/public_html/supercerebro/api/proposals.php 2>&1
#1776644891
php -d display_errors=1 -d error_reporting=32767 -r "
\$_GET['action']='list';
\$_GET['client_id']='6';
include '/home/dimark93/public_html/supercerebro/api/proposals.php';
" 2>&1php -d display_errors=1 -d error_reporting=32767 -r "
\$_GET['action']='list';
\$_GET['client_id']='6';
include '/home/dimark93/public_html/supercerebro/api/proposals.php';
" 2>&1
#1776644918
php -d display_errors=1 -r "\$_GET['action']='list'; \$_GET['client_id']='6'; include '/home/dimark93/public_html/supercerebro/api/proposals.php';" 2>&1
#1776644936
cat /home/dimark93/public_html/supercerebro/auth.php
#1776644963
curl -v "https://dimark.co/supercerebro/api/proposals.php?action=list&client_id=6" 2>&1 | head -30
#1776644978
curl -s -o /dev/null -w "%{http_code}" "https://dimark.co/supercerebro/api/proposals.php?action=list&client_id=6"
#1776644992
cat /home/dimark93/public_html/supercerebro/db.php
#1776645020
nano /home/dimark93/public_html/supercerebro/api/proposals.php
#1776645162
curl -s -o /dev/null -w "%{http_code}" "https://dimark.co/supercerebro/api/proposals.php?action=list&client_id=6"
#1776652471
curl -s "https://dimark.co/supercerebro/api/proposals.php?action=list&client_id=6"
