I would STRONGLY suggest not to hardcode script files in your image tags or to put any executable scripts outside your protected folder. This is a potential security risk. Try to wrap the logic inside a widget and use that to output the appropriate image tags. If you need a thumbnail creator (just guessing) you could use something like http://www.yiiframework.com/extension/ephpthumb or http://www.yiiframework.com/extension/justintimeimageresizer to create thumbnails on the fly if needed.
So the question merely is: What do you want to achieve with your script?
Yes, you could, but you should not. Inside /protected there is a .htaccess file with:
deny from all
You should rather think of a way how to accomplish that, without exposing your script. The way you suggested, you would also have to duplicate code, because createWebApplication() is just called in the entry script (index.php). Without going through this you either have to call createWebApplication() another time or you can’t usee yii advantages.
Take a look at Haensel’s post on how you can achieve this, without having to change your .htaccess and duplicate code.
I was also on the same situation. What I did was copy the jpgraph files into /protected/vendors.
Then on the controller I create actions that will create the graphs.
Example:
public function actionSimpleLine1Graph() {
Yii::import('application.vendors.jpgraph.*');
require_once ('jpgraph.php');
require_once ('jpgraph_line.php');
// Some (random) data
$ydata = array(11, 3, 8, 12, 5, 1, 9, 13, 5, 7);
// Size of the overall graph
$width = 350;
$height = 250;
// Create the graph and set a scale.
// These two calls are always required
$graph = new Graph($width, $height);
$graph->SetScale('intlin');
// Create the linear plot
$lineplot = new LinePlot($ydata);
// Add the plot to the graph
$graph->Add($lineplot);
// Display the graph
$graph->Stroke();
}
Next I created another action on the controller to render the view file.
On the view file I put there the image tag then the url to the controller action that will create/draw the jpgraph image.